<template>
  <div class="navbar_box" :style="{ backgroundColor: bColor, color: color }">
    {{ title }}
    <svg class="left_icon" aria-hidden="true" @click="toBack">
      <slot></slot>
    </svg>
  </div>
</template>

<script>
import { useRouter } from "vue-router";

export default {
  name: "NavBar",
  props: {
    title: {
      type: String,
    },
    bColor: {
      type: String,
      default: "#ff89171f",
    },
    color: {
      type: String,
      default: "#ad7a4a",
    },
  },
  setup() {
    const router = useRouter();
    const toBack = () => {
      router.push("/");
    };
    return { toBack };
  },
};
</script>

<style scoped lang="less">
.navbar_box {
  position: relative;
  width: 100%;
  height: 2.5rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #ff89171f;
  color: #ad7a4a;
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 0.2rem;
  .left_icon {
    position: absolute;
    left: 0.6rem;
    top: 0.36rem;
    width: 1.6em;
    height: 1.6em;
    vertical-align: -0.15em;
    fill: currentColor;
  }
}
</style>
